1
2
3
4 <?php include (
"../inc/connect.inc.php" ); ?>
5 <?php
6 ob_start();
7 session_start();

8 if
(!isset($_SESSION['admin_login'])) {
9     header(
"location: login.php");
10     $user =
"";
11 }

12 else
{
13     $user = $_SESSION[
'admin_login'];
14     $result = mysql_query(
"SELECT * FROM admin WHERE id='$user'");
15         $get_user_email = mysql_fetch_assoc($result);
16             $uname_db = $get_user_email[
'firstName'];
17 }

18
19 if
(isset($_POST['signup'])) {
20 //declere veriable

21 $u_fname = $_POST[
'first_name'];
22 $u_lname = $_POST[
'last_name'];
23 $u_email = $_POST[
'email'];
24 $u_mobile = $_POST[
'mobile'];
25 $u_address = $_POST[
'signupaddress'];
26 //triming name

27 $_POST[
'first_name'] = trim($_POST['first_name']);
28 $_POST[
'last_name'] = trim($_POST['last_name']);
29     
try {
30         
if(empty($_POST['first_name'])) {
31             
throw new Exception('Fullname can not be empty');
32             
33         }
34         
if (is_numeric($_POST['first_name'][0])) {
35             
throw new Exception('Please write your correct name!');
36
37         }
38         
if(empty($_POST['last_name'])) {
39             
throw new Exception('Lastname can not be empty');
40             
41         }
42         
if (is_numeric($_POST['last_name'][0])) {
43             
throw new Exception('lastname first character must be a letter!');
44
45         }
46         
if(empty($_POST['email'])) {
47             
throw new Exception('Email can not be empty');
48             
49         }
50         
if(empty($_POST['mobile'])) {
51             
throw new Exception('Mobile can not be empty');
52             
53         }
54         
if(empty($_POST['password'])) {
55             
throw new Exception('Password can not be empty');
56             
57         }
58         
if(empty($_POST['admintype'])) {
59             
throw new Exception('Admin Type can not be empty');
60             
61         }
62         
if(empty($_POST['signupaddress'])) {
63             
throw new Exception('Address can not be empty');
64             
65         }
66
67         
68         
// Check if email already exists
69         
70         $check =
0;
71         $e_check = mysql_query(
"SELECT email FROM `admin` WHERE email='$u_email'");
72         $email_check = mysql_num_rows($e_check);
73         
if (strlen($_POST['first_name']) >2 && strlen($_POST['first_name']) <16 ) {
74             
if ($check == 0 ) {
75                 
if ($email_check == 0) {
76                     
if (strlen($_POST['password']) >4 ) {
77                         $d = date(
"Y-m-d"); //Year - Month - Day
78                         $_POST[
'first_name'] = ucwords($_POST['first_name']);
79                         $_POST[
'last_name'] = ucwords($_POST['last_name']);
80                         $_POST[
'password'] = md5($_POST['password']);
81                         $confirmCode = substr( rand() *
900000 + 100000, 0, 6 );
82                         
// send email
83                         $msg =
"
84                         Assalamu Alaikum...
85                         
86                         Your activation code: "
.$confirmCode."
87                         Signup email: "
.$_POST['email']."
88                         
89                         "
;
90                         
//if (@mail($_POST['email'],"eBuyBD Activation Code",$msg, "From:eBuyBD <no-reply@ebuybd.xyz>")) {
91                             
92                         $result = mysql_query(
"INSERT INTO admin (firstName,lastName,email,mobile,address,password,type,confirmCode) VALUES ('$_POST[first_name]','$_POST[last_name]','$_POST[email]','$_POST[mobile]','$_POST[signupaddress]','$_POST[password]','$_POST[admintype]','$confirmCode')");
93                         
94                         
//success message
95                         $success_message =
'
96                         <div
class="signupform_content"><h2><font face="bookman">Admin Registration Successfull!</font></h2>
97                         <div
class="signupform_text" style="font-size: 18px; text-align: center;">
98                         <font face=
"bookman">
99                             Email:
'.$u_email.'<br>
100                             Account Successfully Created. <br>
101                         </font></div></div>
';
102                         
//}else {
103                         
// throw new Exception('Email is not valid!');
104                         
//}
105                         
106                         
107                     }
else {
108                         
throw new Exception('Password must be 5 or more then 5 characters!');
109                     }
110                 }
else {
111                     
throw new Exception('Email already taken!');
112                 }
113             }
else {
114                 
throw new Exception('Username already taken!');
115             }
116         }
else {
117             
throw new Exception('Firstname must be 2-15 characters!');
118         }
119
120     }
121     
catch(Exception $e) {
122         $error_message = $e->getMessage();
123     }
124 }
125
126 $search_value =
"";
127 ?>
128
129
130 <!doctype html>
131 <html>
132     <head>
133         <title>Welcome to ebuybd online shop</title>
134         <link rel=
"stylesheet" type="text/css" href="../css/style.css">
135     </head>
136     <body
class="home-welcome-text" style="background-image: url(../image/homebackgrndimg2.png);">
137         <div
class="homepageheader">
138             <div
class="signinButton loginButton">
139                 <div
class="uiloginbutton signinButton loginButton" style="margin-right: 40px;">
140                     <?php
141                         
if ($user!="") {
142                             echo
'<a style="text-decoration: none; color: #fff;" href="logout.php">LOG OUT</a>';
143                         }
144                      ?>
145                     
146                 </div>
147                 <div
class="uiloginbutton signinButton loginButton">
148                     <?php
149                         
if ($user!="") {
150                             echo
'<a style="text-decoration: none; color: #fff;" href="login.php">Hi '.$uname_db.'</a>';
151                         }
152                         
else {
153                             echo
'<a style="text-decoration: none; color: #fff;" href="login.php">LOG IN</a>';
154                         }
155                      ?>
156                 </div>
157             </div>
158             <div style=
"float: left; margin: 5px 0px 0px 23px;">
159                 <a href=
"index.php">
160                     <img style=
" height: 75px; width: 130px;" src="../image/ebuybdlogo.png">
161                 </a>
162             </div>
163             <div id=
"srcheader">
164                 <form id=
"newsearch" method="get" action="search.php">
165                         <?php
166                             echo
'<input type="text" class="srctextinput" name="keywords" size="21" maxlength="120" placeholder="Search Here..." value="'.$search_value.'"><input type="submit" value="search" class="srcbutton" >';
167                          ?>
168                 </form>
169             <div
class="srcclear"></div>
170             </div>
171         </div>
172         <div
class="categolis">
173             <table>
174                 <tr>
175                     <th>
176                         <a href=
"index.php" style="text-decoration: none;color: #fff;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Home</a>
177                     </th>
178                     <th><a href=
"addproduct.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Add Product</a></th>
179                     <th><a href=
"newadmin.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #24bfae;border-radius: 12px;">New Admin</a></th>
180                     <th><a href=
"allproducts.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">All Products</a></th>
181                     <th><a href=
"orders.php" style="text-decoration: none;color: #ddd;padding: 4px 12px;background-color: #c7587e;border-radius: 12px;">Orders</a></th>
182                 </tr>
183             </table>
184         </div>
185         <?php
186             
if(isset($success_message)) {echo $success_message;}
187             
else {
188                 echo
'
189                     <div
class="holecontainer" style="float: right; margin-right: 36%; padding-top: 20px;">
190                         <div
class="container">
191                             <div>
192                                 <div>
193                                     <div
class="signupform_content">
194                                         <h2>New Admin Form!</h2>
195                                         <div
class="signupform_text"></div>
196                                         <div>
197                                             <form action=
"" method="POST" class="registration">
198                                                 <div
class="signup_form">
199                                                     <div>
200                                                         <td >
201                                                             <input name=
"first_name" id="first_name" placeholder="First Name" required="required" class="first_name signupbox" type="text" size="30" value="" >
202                                                         </td>
203                                                     </div>
204                                                     <div>
205                                                         <td >
206                                                             <input name=
"last_name" id="last_name" placeholder="Last Name" required="required" class="last_name signupbox" type="text" size="30" value="" >
207                                                         </td>
208                                                     </div>
209                                                     <div>
210                                                         <td>
211                                                             <input name=
"email" placeholder="Enter Your Email" required="required" class="email signupbox" type="email" size="30" value="">
212                                                         </td
213             >                                       </div>
214                                                     <div>
215                                                         <td>
216                                                             <input name=
"mobile" placeholder="Enter Your Mobile" required="required" class="email signupbox" type="text" size="30" value="">
217                                                         </td>
218                                                     </div>
219                                                     <div>
220                                                         <td>
221                                                             <input name=
"signupaddress" placeholder="Write Your Full Address" required="required" class="email signupbox" type="text" size="30" value="">
222                                                         </td>
223                                                     </div>
224                                                     <div>
225                                                         <td>
226                                                             <input name=
"password" id="password-1" required="required" placeholder="Enter New Password" class="password signupbox " type="password" size="30" value="">
227                                                         </td>
228                                                     </div>
229                                                     <div>
230                                                         <td>
231                                                             <
select name="admintype" required="required" style=" font-size: 20px;
232                                                         font-style: italic;margin-bottom: 3px;margin-top: 0px;padding: 14px;line-height: 25px;border-radius: 4px;border: 1px solid #
169E8F;color: #169E8F;margin-left: 0;width: 300px;background-color: transparent;" class="">
233                                                                 <option selected
value="manager">Manager</option>
234                                                                 <option
value="seller">Seller</option>
235                                                                 <option
value="other">Other</option>
236                                                             </
select>
237                                                         </td>
238                                                     </div>
239                                                     <div>
240                                                         <input name=
"signup" class="uisignupbutton signupbutton" type="submit" value="Add Admin!">
241                                                     </div>
242                                                     <div
class="signup_error_msg">
243                                                         <?php
244                                                             
if (isset($error_message)) {echo $error_message;}
245                                                             
246                                                         ?>
247                                                     </div>
248                                                 </div>
249                                             </form>
250                                             
251                                         </div>
252                                     </div>
253                                 </div>
254                             </div>
255                         </div>
256                     </div>
257                 
';
258             }
259
260          ?>
261     </body>
262 </html>


Gõ tìm kiếm nhanh...